<?php
namespace App\Http\Controllers\Api\V4;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use DB;

use App\Models\V1\MessageModel;

class MessageController extends Controller{

    /*获得总的信息*/
    public function get_user_message(Request $request){
        $userId = $request->input('userId');
        $messageModel   = new MessageModel();
        $messages       = $messageModel->get_user_message($userId);
        $data = [
            'error_code'    => 200,
            'error_msg'     => 'ok',
            'data'          => $messages
        ];
        $messageModel->read_user_message($userId);
        return response()->json($data);
    }



    /*获得未读的消息数量*/
    public function get_unreaded_message_number($userId){

        $messageModel = new MessageModel();
        $number     = $messageModel->get_unreaded_message_number($userId);
        return $number;
    }
}